# -*- encoding: utf-8 -*-
import time
import random
from flask import Flask, render_template, request, redirect, session

# 实例化一个app
app = Flask(__name__)


with open('my_file.txt', 'r', encoding='utf-8') as f:
    data_list = f.readlines()


@app.route('/')
def index_n():
    context = dict()
    time_now = time.strftime('%Y-%m-%d %H:%M:%S')
    centence = random.choice(data_list)
    context['time_now'] = time_now
    context['centence'] = centence
    print(centence)
    return render_template('index.html', data=context)


@app.route('/clock')
def clock():
    return render_template('clock.html')


@app.route('/calendar')
def calendar():
    return render_template('online_calendar.html')


@app.route('/back_color')
def back_color():
    return render_template('back_color.html')


@app.route('/sites')
def sites():
    return render_template('sites/index.html')


if __name__ == "__main__":
    app.run(host='0.0.0.0', port=9030)
